import Vue from "vue";
import VueRouter from "vue-router";
import Layout from "@/pages/Main";
import { home, mall, user, other } from "./modules";
const routeList = [home, mall, user, other];

Vue.use(VueRouter);

// const originalPush = VueRouter.prototype.push;
//解决重复点击路由报错问题
// VueRouter.prototype.push = function push(location) {
//   return originalPush.call(this, location).catch((err) => err);
// };

//实例化路由
const router = new VueRouter({
  routes: [
    //主路由
    {
      path: "/",
      component: Layout,
      redirect: "home", //重定向
    },
    ...routeList,
  ],
});

export default router;
